package com.xy.shop.wechat.handler.gzh1;

import com.xy.shop.wechat.config.WxConfig;
import com.xy.shop.wechat.config.WxGzh1Config;
import com.xy.shop.wechat.handler.UnsubscribeHandler;
import com.xy.shop.wechat.service.WechatSubscribeService;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class Gzh1UnSubscribeHandler extends UnsubscribeHandler
{
	
	/*@Value("${qshdGameType}")
	private String qshdGameType;*/

	@Resource
	private WechatSubscribeService subscribeService;
	
	@Autowired
	private WxGzh1Config wxGzh1Config;
	
	@Override
	protected WxConfig getWxConfig()
	{
		return this.wxGzh1Config;
	}
	
	@Override
	public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
			Map<String, Object> context, WxMpService wxMpService,
			WxSessionManager sessionManager)
	{
		String openId = wxMessage.getFromUser();
        this.logger.info("取消关注用户 OPENID: " + openId);
		if(!StringUtils.isEmpty(openId)){
			Map<String,Object> map =new ConcurrentHashMap<String,Object>();
			map.put("openid", openId);
			//subscribeService.updateSubByParam(map);
		}
		return null;
	}
}
